package com.example.demo.util;

import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.export.ExcelBatchExportService;
import org.apache.poi.ss.usermodel.Workbook;


/**
 * @author LIN
 * @date 2022-09-03 19:55
 */
public class ExcelBatchExportServer extends ExcelBatchExportService{

    private static ExcelBatchExportServer excelBatchExportServer;

    public static ExcelBatchExportServer getExcelBatchExportServer(ExportParams entity, Class<?> pojoClass) {

        if(excelBatchExportServer!=null){
            return excelBatchExportServer;
        }
        ExcelBatchExportServer server = new ExcelBatchExportServer();
        entity.setCreateHeadRows(true);
        server.init(entity,pojoClass);
        excelBatchExportServer = server;
        return server;
    }

    @Override
    public Workbook closeExportBigExcel() {
        excelBatchExportServer = null;
        return super.closeExportBigExcel();
    }
}
